package com.logos.ruralrevitalization.utils;

import com.logos.ruralrevitalization.mapper.AuthUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@Slf4j
public class RuralLoginUtil {

    @Resource
    private AuthUserMapper authUserMapper;

    public String getId() {
        String loginId = LoginContextHolder.getLoginId();
        if (loginId == null){
            log.info("用户未登录");
            return null;
        }
        return loginId;
    }

    public Integer getType(){
        String loginId = LoginContextHolder.getLoginId();
        if (loginId == null){
            log.info("用户未登录");
            return null;
        }
        return authUserMapper.queryById(Long.parseLong(loginId)).getUserType();
    }
}
